﻿using System.Diagnostics;

namespace DimensionsHelper.Client.ViewModels;

[DebuggerDisplay("{FileName,nq}")]
public partial class FileInfoViewModel : ObservableObject
{
    [ObservableProperty]
    private bool _canRemove;

    [ObservableProperty]
    private string _category = string.Empty;

    [ObservableProperty]
    private string _fileName = string.Empty;

    private Action<FileInfoViewModel>? _removeSelf;

    public event Action<FileInfoViewModel> RemoveSelf
    {
        add
        {
            _removeSelf += value;
            CanRemove = true;
        }

        remove
        {
            _removeSelf -= value;

            if (_removeSelf == null)
            {
                CanRemove = false;
            }
        }
    }


    [RelayCommand(CanExecute = nameof(CanRemove))]
    private void Remove()
    {
        _removeSelf?.Invoke(this);
    }
}